package com.example.wanbaqian.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.wanbaqian.R;
import com.example.wanbaqian.base.BaseActivity;
import com.example.wanbaqian.bean.WithdrawalsBean;
import com.example.wanbaqian.utils.ActivityManagerUtils;
import com.example.wanbaqian.utils.TimeUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import butterknife.BindView;

/**
 * 借款进度
 */
public class WithdrawalsProgressActivity extends BaseActivity {
    @BindView(R.id.WithdrawalsProgress_money)
    TextView WithdrawalsProgressMoney;
    @BindView(R.id.WithdrawalsProgress_time)
    TextView WithdrawalsProgressTime;
    @BindView(R.id.WithdrawalsProgress_Bank)
    TextView WithdrawalsProgressBank;
    @BindView(R.id.WithdrawalsProgress_hint)
    TextView WithdrawalsProgressHint;
    @BindView(R.id.WithdrawalsProgress_RecyclerView)
    RecyclerView WithdrawalsProgressRecyclerView;
    private WithdrawalsBean bean;

    @Override
    protected int getLayout() {
        return R.layout.activity_withdrawals_progress;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        bean = (WithdrawalsBean) getIntent().getExtras().getSerializable("bean");
        setStatusBarColor(R.color.colorBackground);
        setToolBar("借款状态");
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != WithdrawalsActivity.instence){
                    WithdrawalsActivity.instence.finish();
                    WithdrawalsActivity.instence = null;
                }
                finish();
            }
        });
        WithdrawalsProgressRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        WithdrawalsProgressRecyclerView.setAdapter(new CommonAdapter<String>(mContext, R.layout.item_withdrawals_pro, listByTest.subList(0, 3)) {
            @Override
            protected void convert(ViewHolder holder, String s, int position) {
                if (position == 0) {
                    holder.getView(R.id.item_wwpro_hint).setVisibility(View.VISIBLE);
                    holder.setText(R.id.item_wwpro_stat, "打款中");
                    holder.setText(R.id.item_wwpro_hintTv, "已进入支付状态,请耐心等待");
                    holder.setText(R.id.item_wwpro_time, TimeUtils.getCurrentTimeByFormat("yyyy-MM-dd HH:mm:ss"));
                } else if (position == 1) {
                    holder.setText(R.id.item_wwpro_stat, "审核通过");
                    holder.setText(R.id.item_wwpro_hintTv, "风控审核通过");
                    holder.setText(R.id.item_wwpro_time, TimeUtils.getCurrentTimeByFormat("yyyy-MM-dd HH:mm:ss"));
                } else {
                    holder.setText(R.id.item_wwpro_stat, "申请提交成功");
                    holder.setText(R.id.item_wwpro_hintTv, "申请借贷成功");
                    holder.setText(R.id.item_wwpro_time, TimeUtils.getCurrentTimeByFormat("yyyy-MM-dd HH:mm:ss"));
                }
            }
        });
    }

    @Override
    protected void initDate() {
        WithdrawalsProgressMoney.setText(bean.getMoney() + "元");
        WithdrawalsProgressTime.setText(bean.getTime() + "天");
        WithdrawalsProgressBank.setText("收款账号:" + bean.getBank_name() + " " + bean.getBank_account());
        ActivityManagerUtils.getInstance().finishActivityclass(WithdrawalsActivity.class);
        ActivityManagerUtils.getInstance().finishActivityclass(WithdrawalsConfirmActivity.class);
    }

}
